﻿if exists (select * from sysobjects where name like N'%sp_DMKhachHang_Insert%')
	drop proc sp_DMKhachHang_Insert
go
create proc sp_DMKhachHang_Insert
	@MaKhachHang varchar(50) = null,
	@TenKhachHang nvarchar(255) = null,
	@TenCongTy nvarchar(255) = null,
	@DiaChi nvarchar(255) = null,
	@DienThoai varchar(50) = null,
	@Fax varchar(50) = null,
	@Website varchar(50) = null,
	@TaiKhoan varchar(50) = null,
	@MaSoThue varchar(50) = null,
	@IsUse bit = null,
	@CreateBy int = null
as
begin
	if not exists (select * from DMKhachHang where MaKhachHang = @MaKhachHang)
	begin
		insert into DMKhachHang (MaKhachHang, TenKhachHang, TenCongTy, DiaChi, DienThoai, Fax, Website, TaiKhoan,
			MaSoThue, IsUse, CreateBy)
		values (@MaKhachHang, @TenKhachHang, @TenCongTy, @DiaChi, @DienThoai, @Fax, @Website, @TaiKhoan,
			@MaSoThue, @IsUse, @CreateBy)
		return 1
	end
	else
	begin
		return 0
	end
end